<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>新增設備資料</title>
</head>
<body>
<% if(session.getAttribute("access") == "y" ){%>
<jsp:useBean id="mydb" scope="page" class="bean.ConDbBean"/> <%//連結資料庫的bean %>
<%
String fid = new String(request.getParameter("id").getBytes("iso-8859-1"),"utf-8"); //防止亂碼
String fname=new String(request.getParameter("name").getBytes("iso-8859-1"),"utf-8");
String fdetail=new String(request.getParameter("detail").getBytes("iso-8859-1"),"utf-8");
String fps= new String(request.getParameter("ps").getBytes("iso-8859-1"),"utf-8");
String fclass= new String(request.getParameter("class").getBytes("iso-8859-1"),"utf-8");
String fimage="image";
//java.net.URLEncoder.encode(keyword,"UTF-8") 丟出中文字串的寫法
String sql="INSERT INTO FACILITY(F_ID,F_NAME,F_STATE,F_DETAIL,PS,IMAGE,F_CLASS) VALUES('"+fid+"','"+fname+"','00','"+fdetail+"','"+fps+"','"+fimage+"','"+fclass+"')";
mydb.executeInsert(sql);
//out.print(fid+","+fname+","+fdetail+","+fps+","+fclass+","+fimage);
response.sendRedirect("lookFacility.jsp"); //直接跳頁到lookFacility.jsp
%>

<%
  }
  else{
  	response.sendRedirect("../index.jsp"); //若沒有登入則回到index.jsp
  } 
  %>
</body>
</html>